Chapter 21: Inference for comparing paired means

Overview

  • 21.1 Randomization test for the mean paired difference
    • 21.1.1 Observed data
    • 21.1.2 Variability of the statistic
    • 21.1.3 Observed statistic vs. null statistics
  • 21.2 Bootstrap confidence interval for the mean paired difference
    • 21.2.1 Observed data
    • 21.2.2 Variability of the statistic
  • 21.3 Mathematical model for the mean paired difference
    • 21.3.1 Observed data
    • 21.3.2 Variability of the statistic
    • 21.3.3 Observed statistic vs. null statistics

Paired Designs

How would you collect data to answer the following questions?

  • You want to compare grocery prices between Vons and Trader Joe’s. Are prices different, on average?
  • You want to test “The Freshmen 10” theory. Do college students gain, on average, 10 pounds during their first year?

Reducing variability

  • The paired data sets in this chapter have one pair of quantitative response values for each observational unit, allowing for a built-in comparison.
  • Studies with paired data remove individual variability by looking at the difference score for each individual.
  • Reducing variability in data improves inferences:
    • Narrower confidence intervals
    • Smaller p-values when the null hypothesis is false (more power)

21.1 Randomization test for the mean paired difference

Example: Compare tread wear between two brands of tire.

  • 25 cars. Each car had one tire of each brand.
  • After 1000 miles, the tread reamaining was measured.

Hypotheses

  • \(H_0: \mu_\text{diff} = 0\), the average tread wear is the same for the two tire brands.
  • \(H_A: \mu_\text{diff} \neq 0\), the average tread wear is different across the two tire brands.

Observed Statistic: \(\bar{x}_\text{diff} = -0.002\)

Randomization: Flip a coin for each pair. If heads, reverse the pair. If tails, leave it as is.

21.1.1 Observed data

21.1.2 Variability of the statistic

21.1.3 Observed statistic vs. null statistics

Jumping Jacks vs Bicycle Kicks

Preview

Which common exercise, jumping jacks or bicycle kicks, raises your heart rate more?

\[ \begin{align} H_0: \mu_d &= 0 \\ H_a: \mu_d &\neq 0 \\ \bar{x}_d &\approx 11.9545 \end{align} \]

    JJ bicycle
1  118     118
2  146     124
3  134      92
4   94      80
5  146     111
6  114     112
7  132     124
8  118     124
9  116      97
10 101      82
11 112     143
12  99      97
13 112      88
14 118     123
15  88      83
16  70      73
17 106      87
18 108     137
19 124      98
20 143      96
21  92      70
22 131     100

Group Activity

  1. Go to the Matched Pairs applet, and select the JJvsBicycle data from the dropdown menu. Discuss the following:
    • In the top graph, what do the red dots, blue dots, and gray lines represent?
    • In the bottom graph, what do the dots represent?
  2. Check the box for Randomize and then click on the Randomize button.
    • What do the coin flips determine?
    • How is the dot on the null distribution calculated?
  3. Perform 1000 (or more) randomizations, and record a p-value for the above test. In the context of the problem (exercise), record a sentence saying what this p-value tells us.

21.2 Bootstrap confidence interval for the mean paired difference

  • Bootstrapping works the same as in the one-mean case.
  • Resample the data, and compute bootstrapped \(\bar{x}_\text{diff}\)’s.
  • Make a bootstrapped distribution.

21.3 Mathematical model for the mean paired difference

Example. Data on 68 textbooks, giving their bookstrore price and their price on Amazon.

glimpse(textbooks)
Rows: 68
Columns: 5
$ subject       <fct> "American Indian Studies", "Anthropology", "Arts and Architecture", "Asian",…
$ course_num    <fct> M10, 2, 10, M60W, 4, 10, 2CW, 10, 19, 1A, 4, 2, 3, 3A, 12B, 1A, 1, 19, 20, 1…
$ bookstore_new <dbl> 47.97, 14.26, 13.50, 49.26, 119.97, 16.95, 11.96, 26.75, 9.96, 39.97, 132.75…
$ amazon_new    <dbl> 47.45, 13.55, 12.53, 54.95, 124.80, 11.77, 10.87, 38.94, 8.99, 35.00, 78.67,…
$ price_diff    <dbl> 0.52, 0.71, 0.97, -5.69, -4.83, 5.18, 1.09, -12.19, 0.97, 4.97, 54.08, -2.98…

21.3.1 Observed data

ggplot(textbooks, aes(x = price_diff)) + geom_histogram(binwidth = 5)

21.3.2 Variability of the statistic

textbooks %>%
  summarize(n = n(),
            meanDiff = mean(price_diff),
            sdDiff = sd(price_diff))
# A tibble: 1 × 3
      n meanDiff sdDiff
  <int>    <dbl>  <dbl>
1    68     3.58   13.4

Hypotheses

  • \(H_0: \mu_\text{diff} = 0\), there is no difference in the average textbook price between the bookstore and Amazon
  • \(H_A: \mu_\text{diff} \neq 0\), there is a difference in the average price.

21.3.3 Observed statistic vs. null statistics

The mathematical model is very similar to the one-mean case:

\[ T = \frac{\bar{x}_\text{diff} - 0}{s_\text{diff}/\sqrt{n}} \]

The conditions are similar: Independence, large samples, or normality of the differences.

Confidence interval for the mean difference

A confidence interval for \(\mu_\text{diff}\) is:

\[ \bar{x}_\text{diff} \pm t^\star_\text{df} \times \frac{s_\text{diff}}{\sqrt{n}} \]

As before, \(df = n-1\). Use qt() to get \(t^\star\).

Group Exercise

# A tibble: 1 × 3
      n meanDiff sdDiff
  <int>    <dbl>  <dbl>
1    68     3.58   13.4
  1. Use the mathematical model to perform the above hypothesis test. Obtain a \(T\) score using the formula and a P-value using pt(). Write a sentence explaining your conclusion in context.

  2. Use the mathematical model to construct a 95% confidence interval for the mean difference in price between the bookstore and Amazon. Write a sentence interpreting your confidence interval in context.

Paired t-test in R

Have R compute the differences

t.test(textbooks$bookstore_new, textbooks$amazon_new, paired = TRUE)

    Paired t-test

data:  textbooks$bookstore_new and textbooks$amazon_new
t = 2.2012, df = 67, p-value = 0.03117
alternative hypothesis: true mean difference is not equal to 0
95 percent confidence interval:
 0.3340641 6.8324064
sample estimates:
mean difference 
       3.583235 

Just to a one-sample test on the differences

t.test(textbooks$price_diff)

    One Sample t-test

data:  textbooks$price_diff
t = 2.2012, df = 67, p-value = 0.03117
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
 0.3340641 6.8324064
sample estimates:
mean of x 
 3.583235